<?php

namespace common\models\notice;

use common\helpers\Url;
use Yii;

/**
 * This is the model class for table "{{%notice_attach}}".
 *
 * @property int $id
 * @property int $notice_id 通告ID
 * @property string $path 路径
 * @property string $description 描述
 * @property int $image 附件类型：1图片，0文件
 * @property int $status 状态
 * @property int $created_at
 * @property int $updated_at
 */
class NoticeAttach extends \common\db\ActiveRecord
{
    /**
     * {@inheritdoc}
     */
    public static function tableName()
    {
        return '{{%notice_attach}}';
    }

    /**
     * {@inheritdoc}
     */
    public function rules()
    {
        return [
            [['notice_id', 'image', 'status', 'created_at', 'updated_at'], 'integer'],
            [['path'], 'required'],
            [['path', 'description'], 'string', 'max' => 255],
        ];
    }

    /**
     * {@inheritdoc}
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'notice_id' => '通告ID',
            'path' => '路径',
            'description' => '描述',
            'image' => '附件类型：1图片，0文件',
            'status' => '状态',
            'created_at' => 'Created At',
            'updated_at' => 'Updated At',
        ];
    }

    public function fields()
    {
        return [
            'path' => function () {
                return Url::attach($this->path);
            },
        ];
    }
}
